//
//  MessageViewController.swift
//  FXWB
//
//  Created by iSolar on 2017/3/9.
//  Copyright © 2017年 iSolar. All rights reserved.
//

import UIKit

let message = "messageTableViewCell";

class MessageViewController: UITableViewController {

    var images = ["at","comment","zan","weiguanzhu","dingyue"]
    var titleArr = ["@我的","评论","赞","未关注人消息","订阅消息"]

    override func viewDidLoad() {
        super.viewDidLoad()
        let requesterNib = UINib(nibName: "MessageTableViewCell", bundle: nil)
        tableView.register(requesterNib, forCellReuseIdentifier: message)
    }
}

extension MessageViewController {
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return images.count
    }
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        // 1.创建cell
        let cell = tableView.dequeueReusableCell(withIdentifier: message) as! MessageTableViewCell
        cell.selectionStyle = UITableViewCellSelectionStyle.none
        var str: NSString = NSString();
        str = images[indexPath.item] as NSString
        cell.iconImage = UIImage(named:str as String)
        cell.title.text = indexPath.item <= titleArr.count - 1 ? titleArr[indexPath.item] : nil
        return cell;
    }
    
    override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 60
    }
    
    override func tableView(_ tableView: UITableView, didHighlightRowAt indexPath: IndexPath) {
        let cell = tableView.cellForRow(at: indexPath)
        cell?.backgroundColor = UIColor.white
    }
}
